package logic.cmd
{
	import common.core.GEevnt;
	import common.manager.GUI;
	import common.manager.ObserverEvt;
	
	import component.show.containers.*;
	import component.untils.ComponentItem;
	
	import fl.containers.ScrollPane;
	import fl.containers.UILoader;
	import fl.controls.Button;
	import fl.controls.CheckBox;
	import fl.controls.ComboBox;
	import fl.controls.DataGrid;
	import fl.controls.Label;
	import fl.controls.List;
	import fl.controls.TextArea;
	import fl.controls.TextInput;
	
	import logic.manager.UIProxy;
	import logic.ui.*;
	import logic.ui.componentInfoMed.*;

	public class OpenCompoentInfoMedCMD
	{
		public static const NAME  : String = "OPENCOMPONENTINFOMEDCMD";
		public static const OPENCOMPENTINFOMED : String = "OpenCompoentInfoMedCMD_OPENCOMPENTINFOMED";
		public static const OPENCOPLETE : String = "OpenComponentInfoMedCMD_OpenCompete";
		
		private var m_target : ComponentItem;
		
		public function OpenCompoentInfoMedCMD()
		{
			ObserverEvt.addRec(OPENCOMPENTINFOMED,this,openInfoMed);
		}
		
		public function destory() : void
		{
			ObserverEvt.removeRec(OPENCOMPENTINFOMED,this,openInfoMed);
			
			m_target = null;
		}
		
		private function openInfoMed(evt : GEevnt) : void
		{
			m_target = evt.data;
			
			
			if(!m_target) return;
			
			var com : * = m_target.item;
			
			UIProxy.stopAll();
			
			if(com is Label)
			{
				UIProxy.Label.start();
				
				(GUI.find(LabelInfoMed.NAME) as LabelInfoMed).target = m_target;
			}
			else if(com is Button)
			{
				UIProxy.Button.start();
				
				(GUI.find(ButtonInfoMed.NAME) as ButtonInfoMed).target = m_target;
			}
			else if(com is List)
			{
				UIProxy.List.start();
				
				(GUI.find(ListInfoMed.NAME) as ListInfoMed).target = m_target;
			}
			else if(com is ComboBox)
			{
				UIProxy.ComboBox.start();
				
				(GUI.find(ComboBoxInfoMed.NAME) as ComboBoxInfoMed).target = m_target;
			}
			else if(com is Image)
			{
				UIProxy.Image.start();
				
				(GUI.find(ImageInfoMed.NAME) as ImageInfoMed).target = m_target;
			}
			else if(com is TextInput)
			{
				UIProxy.TextInput.start();
				
				(GUI.find(TextInputInfoMed.NAME) as TextInputInfoMed).target = m_target;
			}
			else if(com is TextArea)
			{
				UIProxy.TextArea.start();
				
				(GUI.find(TextAreaInfoMed.NAME) as TextAreaInfoMed).target = m_target;
			}
			else if(com is List)
			{
				UIProxy.List.start();
				
				(GUI.find(ListInfoMed.NAME) as ListInfoMed).target = m_target;
			}
			else if(com is DataGrid)
			{
				UIProxy.DataGrid.start();
				
				(GUI.find(DataGridInfoMed.NAME) as DataGridInfoMed).target = m_target;
			}
			else if(com is UILoader)
			{
				UIProxy.UILoader.start();
				
				(GUI.find(UILoaderInfoMed.NAME) as UILoaderInfoMed).target = m_target;
			}
			else if(com is CheckBox)
			{
				UIProxy.CheckBox.start();
				
				(GUI.find(CheckBoxInfoMed.NAME) as CheckBoxInfoMed).target = m_target;
			}
			else if(com is UIFrame)
			{
				UIProxy.UIFrame.start();
				
				(GUI.find(UIFrameInfoMed.NAME) as UIFrameInfoMed).target = m_target;
			}
			else if(com is SimpleBtn)
			{
				UIProxy.SimpleBtn.start();
				
				(GUI.find(SimpleBtnInfoMed.NAME) as SimpleBtnInfoMed).target = m_target;
			}
			else if(com is ScrollPane)
			{
				UIProxy.ScrollPane.start();
				
				(GUI.find(ScrollPaneInfoMed.NAME) as ScrollPaneInfoMed).target = m_target;
			}
			else if(com is ToggleButton)
			{
				UIProxy.ToggleButton.start();
				
				(GUI.find(ToggleButtonInfoMed.NAME) as ToggleButtonInfoMed).target = m_target;
			}
			
			ObserverEvt.Send(OPENCOPLETE);
		}
	}
}